/*
	顺序栈的实现
*/

#include "sqstack.h"

int main(void)
{
	sqstack *stack = stack_create();
	if (stack == NULL)
		exit(1);

	datatype arr[] = {19, 23, 11, 45, 67};

	int ret;

	for (int i = 0; i < sizeof(arr) / sizeof(*arr); i++)
	{
		ret = stack_push(stack, &arr[i]);
		if (ret != 0)
		{
			printf("st_push failed\n");
			exit(2);
		}
	}

	int tmp = 1;

	ret = stack_push(stack, &tmp);

	if (ret != 0)
		printf("st_push failed\n");
	else
		stack_show(stack); //最不需要的功能，主要目的是写程序时看到效果

	while (stack_pop(stack, &tmp) == 0)
	if (ret == 0)
		printf("top = %d\n", tmp);
	else
		printf("栈为空\n");

	stack_destory(&stack);

	sqstack *match_stack = stack_create();
	char *expression = "((a+b))()";
	ret = PrintMatchedPairs(match_stack, expression);
	if (ret == -1)
		printf("左右括号不匹配!\n");
	else
		printf("左右括号匹配!\n");

	return 0;
}
